<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activIdsAdmin']))
{
	header("Location:checkLogin.php");
}
else
{
if(isset($_REQUEST['submit']))
{
  $loopCntDetail = 0;
  while($loopCntDetail < count($_POST['itemPrice']))
  {
  	$itemName   = isset($_POST['itemName'][$loopCntDetail]) ? $_POST['itemName'][$loopCntDetail] : "";
  	$itemPrice  = isset($_POST['itemPrice'][$loopCntDetail]) ? $_POST['itemPrice'][$loopCntDetail] : 0;
    if($itemPrice > 0)
    {
      $insertItem = "INSERT INTO item (itemName,itemPrice)
                             VALUES('".$itemName."',".$itemPrice.")";
      $insertItemRes = mysql_query($insertItem);
      if(!$insertItemRes)
      {
      	die ("Insert Query Not Insertd :" .mysql_error());    
      }
      else
      {
        header("Location:item.php");
      }
    }
    $loopCntDetail++;
  }
}

include("bottom.php");
$smarty->display("item.tpl");
}
?>